home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6185 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Easiest way to center a string?
  5. Date: Thu, 22 Feb 96 23:50:30 GMT
  6. Organization: none
  7. Distribution: world
  8. Message-ID: <825033030snz@genesis.demon.co.uk>
  9. References: <Pine.A32.3.91.960221155136.193887A@red.weeg.uiowa.edu>
  10. Reply-To: fred@genesis.demon.co.uk
  11. X-NNTP-Posting-Host: genesis.demon.co.uk
  12. X-Newsreader: Demon Internet Simple News v1.27
  13. X-Mail2News-Path: genesis.demon.co.uk
  14.  
  15. In article <Pine.A32.3.91.960221155136.193887A@red.weeg.uiowa.edu>
  16.            robinson@blue.weeg.uiowa.edu "The Amorphous Mass" writes:
  17.  
  18. >On 22 Feb 1996, Simon Hosie wrote:
  19. >
  20. >> Simon Hosie:
  21. >> > printf("%*s\n", (strlen(String - LineLen) / 2, String);
  22. >> Simon Hosie:
  23. >> >   Sorry, make that:
  24. >> > printf("%*s\n", (strlen(String + LineLen)) / 2, String);
  25. >> 
  26. >>   If this one is wrong I'm not correcting myself again, I promise (I haven't
  27. >> been getting enough sleep, ok?)..
  28. >> 
  29. >> printf("%*s\n", (strlen(String) + LineLen) / 2, String);
  30. >
  31. >  Since I have managed to make a complete fool out of myself on this 
  32. >thread previously (thanks to Tanmoy and Lawrence for being so indulgent, 
  33.  
  34. Indulgent? Public humiliation is usually far more effective than
  35. simple flaming! ;-)
  36.  
  37. >and my apologies to Simon for being completely wrong in my critique), I will 
  38. >think this response through _very_ carefully.  As Lawrence pointed out, 
  39. >you need to cast that expression to int, because printf() expects an int 
  40. >and not a size_t (which might not fit into an int).  So use
  41. >
  42. >   printf("*s\n", (int)((strlen(String) + LineLen) / 2), String);
  43.  
  44.             ^
  45. I think a % here would help! :-))
  46.  
  47. -- 
  48. -----------------------------------------
  49. Lawrence Kirby | fred@genesis.demon.co.uk
  50. Wilts, England | 70734.126@compuserve.com
  51. -----------------------------------------
  52.